From 0bf630c39fe290ea2718eab7a0759d978c736ef9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Nov 2024 13:08:08 -0800 Subject: bip21 and socket fixes --- .../(app)/send/bitcoin/[address]/+layout.server.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/routes/(app)/send/bitcoin/[address]/+layout.server.ts') diff --git a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts index 68191311..a321ec43 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts @@ -4,20 +4,22 @@ import { redirect } from "@sveltejs/kit"; export async function load({ cookies, params, parent }) { const { user } = await parent(); const aid = cookies.get("aid"); - const { address } = params; + const { address, amount } = params; const { balance } = await get(`/account/${aid}`, auth(cookies)); + let invoice; try { - const invoice = await get(`/invoice/${address}`); - - if (invoice) { - const recipient = await get(`/users/${invoice.uid}`); - if (recipient?.id !== user.id) - redirect(307, `/pay/${recipient.username}`); - } + invoice = await get(`/invoice/${address}`); } catch (e) { // invoice not found } + if (invoice) { + const recipient = await get(`/users/${invoice.uid}`); + let r = `/pay/${recipient.username}`; + if (amount) r += `/${amount}`; + if (recipient?.id !== user.id) redirect(307, r); + } + return { balance }; } -- cgit v1.2.3